<?php

namespace FrontModule;

class SanitaPresenter extends FrontPresenter {

    public function renderDefault() {
        $sanitaryModel = new \AdminModule\Models\Sanitary($this->db);
        $this->template->sanitaryList = $sanitaryModel->where('published = ?', array(true))->order('id_sanitary DESC');
    }
    
    public function renderDetail($id, $zbozi) {        
        $sanitaryModel = new \AdminModule\Models\Sanitary($this->db);
        $sanitary = $sanitaryModel->get($id);
        if (!$sanitary instanceof \Nette\Database\Table\ActiveRow) {
            $this->flashMessage('Položka sanity s id ' . $id . ' neexistuje', 'error');
            $this->redirect('default');
        }
        $this->template->sanitary = $sanitary;
    }

}
